﻿using System;
using System.Collections.Generic;
using System.Formats.Tar;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PerpheralDevice.Units;
/// <summary>
///  物理输出开关基类
/// </summary>
public abstract class SwitchRW : Switch {

    public abstract SwitchRW Open();

    public abstract SwitchRW Shut();

    protected SwitchRW MockView() {
        this.OnStatusChangedRaise();
        return this;
    }

    protected SwitchRW MockOpen() {
        if (this.PerpDev.IsMocking) {
            if (!(this.IsOpen ?? false)) {
                this.IsOpen = true;
                this.OnStatusChangedRaise();
            }
        }
        return this;
    }

    protected SwitchRW MockShut() {
        if (this.PerpDev.IsMocking) {
            if (this.IsOpen ?? true) {
                this.IsOpen = false;
                this.OnStatusChangedRaise();
            }
        }
        return this;
    }

}
